﻿///<reference path="/js/MicrosoftAjax.js"/>
///<reference path="/js/doo.all.debug.js"/>
///<reference path="/js/imdoo.js"/>

Type.registerNamespace("ImDoo.Controls");

ImDoo.Controls.main = function (elem) {
    ImDoo.Controls.main.initializeBase(this, [elem]);
}

ImDoo.Controls.main.prototype = {
    initialize: function () {
        ImDoo.Controls.main.callBaseMethod(this, 'initialize');

    },
    htmlfile: 'main.htm',
    onChildsReady: function () {
        var _t = this;
        var onLogin = function () {
            _t.findChild("username").innerHTML = UC.Name;
            $show("haslogin", _t);
            _t.findChild("myact").bind();
        };

        if (UC.isLogin()) {
            onLogin();
        }
        else {
            UC.tryLogin(onLogin, function () {
                $show("notlogin", _t);
            });
        };
    },

    newact_updated: function () {
        this.findChild("hotact").bind();
        this.findChild("myact").bind();
    },

    bind_click: function () {
        //应该弹出一个注册框
        var name = prompt("随意输一个名字", "");
        if (!name) return;
        var _t = this;
        UC.Reg({ Name: name }, function () {
            _t.findChild("username").innerHTML = UC.Name;
            $show("haslogin", _t);
            $hide("notlogin", _t);
        }, function () {
            alert("绑定失败，请重试");
        });
    },

    dispose: function () {


        //在此处添加自定义释放操作
        ImDoo.Controls.main.callBaseMethod(this, 'dispose');
    }
}

ImDoo.Controls.main.registerClass('ImDoo.Controls.main', Doo.UserControlBase);